package com.qianfeng.controller;

import com.qianfeng.dto.Page;
import com.qianfeng.entity.ChargeProject;
import com.qianfeng.entity.ChargeProjectRegistration;
import com.qianfeng.entity.Registration;
import com.qianfeng.service.ChargeProjectRegistrationService;
import com.qianfeng.service.ChargeProjectService;
import com.qianfeng.service.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class ChargeProjectRegistrationController {
    @Autowired
    private ChargeProjectService chargeProjectService;
    @Autowired
    private RegistrationService registrationService;
    @Autowired
    private ChargeProjectRegistrationService chargeProjectRegistrationService;

    @RequestMapping("/getCPRList")
    public String getCPRList(){
        return "07_check_charging_item_registration";
    }
    @ResponseBody
    @RequestMapping("/getCPRPage")
    public Page getCPRPage(Integer pageNo,Integer pageSize){
        int pageNo_ = 1;
        int pageSize_ = 2;
        if (pageNo != null) {
            pageNo_ = pageNo;
        }
        if (pageSize != null) {
            pageSize_ = pageSize;
        }
        Page page = chargeProjectRegistrationService.getChargeProjectRegistrationPage(pageNo_, pageSize_);
        return page;
    }
    @RequestMapping("/getCrpDetail")
    public String getCrpDetail(Integer rId, Map map){
        List<ChargeProjectRegistration> chargeProjectRegistrationList = chargeProjectRegistrationService.getChargeProjectRegistrationList(rId);
        map.put("cpr",chargeProjectRegistrationList);
        return "04_01_in_the_hospital_and_settlement_detail";
    }

    @RequestMapping("/jumpAddCpr")
    public String jumpAddCpr(Integer rId,Map map){
        Registration registration = registrationService.getRegistrationById(rId);
        map.put("registration",registration);
        List<ChargeProject> chargeProjectList = chargeProjectService.getChargeProjectList();
        map.put("chargeProject",chargeProjectList);
        return "07_01_check_charging_item_registration_add";
    }
    @RequestMapping("/AddCpr")
    public String AddCpr(Integer rId,Integer cpId){
        chargeProjectRegistrationService.addChargeProjectRegistration(rId, cpId);
        return "07_check_charging_item_registration";
    }


}
